<?php
require_once "WXconfig.php";
header("Content-type: text/html; charset=UTF-8");
//$data = $_GET['cc'];
//$payty = $_GET['paytype'];
//$gettype = $_GET['gettype'];
function doCurlPostRequest($paytype, $amount, $gettp, $timeout = 5)
{
    $urls = Configs::URLWAPPAY;
    $Md5 = Configs::SIGNATURE;
    $merchnos = Configs::MERCHNO;
    $timetraceno = Configs::TIMETRA . date('ymdhis', time());
    $timetraceno = 'zshi1sbd5mjrcuatijnrmvd9wu';
    $certno = Configs::CERTNO;
    $notifyUrl = Configs::NOTIFYURL;
    $accountno = Configs::ACCOUNTNO;
    $account_name = Configs::ACCOUNT_NAME;
    $fee = Configs::FEE;
    $pyte = '';
    $post_data = '';
    $post_data = array(
        'merchno' => $merchnos,
        'amount' => $amount,
        'traceno' => $timetraceno,
        'payType' => $paytype,
        'notifyUrl' => $notifyUrl,
        "goodsName" => '佐丹奴西装',
        'remark' => "remark");
    ksort($post_data);
    $a = '';
    foreach ($post_data as $x => $x_value) {
        $a = $a . $x . "=" . iconv('UTF-8', 'GB2312', $x_value) . "&";
    }
    echo 'md5 conent '.$a . $Md5.'</br>'.'</br>';

    $b = md5($a . $Md5);
    $c = $a . 'signature' . '=' . $b;
    if ($urls == '' || $c == '' || $timeout <= 0) {
        return false;
    }
    echo 'url '.$urls.'</br>'.'</br>';
    $con = curl_init((string) $urls);
    curl_setopt($con, CURLOPT_HEADER, false);
    curl_setopt($con, CURLOPT_POSTFIELDS, $c);
    curl_setopt($con, CURLOPT_POST, true);
    curl_setopt($con, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($con, CURLOPT_TIMEOUT, (int) $timeout);
    return curl_exec($con);
}
//function doCurlPostRequest($paytype, $amount, $gettp, $timeout = 5)
echo iconv('GB2312', 'UTF-8', doCurlPostRequest('1', '1.0',''));